package com.adou.second.day10;

import java.io.FileReader;
import java.io.FileWriter;
import java.util.Properties;

/**
 * 记录游戏次数
 * @author admin
 *
 */
public class PropertiesTest {
	public static void main(String[] args) throws Exception {
		Properties properties = new Properties();
		FileReader fr = new FileReader("fos\\game.properties");
		properties.load(fr);
		fr.close();
		
		String count = properties.getProperty("count");
		Integer num = Integer.parseInt(count);
		
		//
		if(num >= 3){
			System.out.println("游戏已结束，想玩青充钱（www.baidu.com）");
		} else {
			num++;
			RandomDemo.start();
			properties.put("count", String.valueOf(num));
			FileWriter fw = new FileWriter("fos\\game.properties");
			properties.store(fw, null);
			fw.close();
		}
	}
}
